package com.gg.user.gguser.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.gg.header.getHeaderUser;
import com.gg.user.gguser.dao.GgItemsOnlyDaoMapper;
import com.gg.user.gguser.dataobject.GgItemsOnlyDataobject;
import com.gg.user.gguser.service.GgItemsOnlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Service
public class GgItemsOnlyServiceImpl implements GgItemsOnlyService {

    @Autowired
    private GgItemsOnlyDaoMapper ggItemsOnlyDaoMapper;

    // 判断ID是否已经存在
    @Override
    public GgItemsOnlyDataobject judgeItemsOnly(HttpServletResponse response, HttpServletRequest request,String ggIoType) throws Exception {
        try {
            // 从cookice信息中过去用户信息 在这里只用要id就好
            String cookiceUser = getHeaderUser.getHader(response, request, "gg");
            String ggId = JSONObject.parseObject(cookiceUser).getString("ggId");
            GgItemsOnlyDataobject ggItemsOnlyDataobject= new GgItemsOnlyDataobject();
            ggItemsOnlyDataobject.setGgIoType(ggIoType);
            ggItemsOnlyDataobject.setGgId(ggId);
            ggItemsOnlyDaoMapper.addInformation(ggItemsOnlyDataobject);
            return ggItemsOnlyDaoMapper.getInformation(ggItemsOnlyDataobject.getId());
        }catch (Exception e){
            return null;
        }

    }

    // 改变位置属性

    @Override
    public Object changeItemsOnly() {
        return null;
    }
}
